<template>
  <div class="container">
    <navbar
      :vaniconL="true"
      :vaniconR="true"
      :noRight="true"
      :noLeft="false"
      iconNameL="arrow-left"
      iconNameR="search"
      @clickLeft="goBack"
    >{{$t('detailList.detail')}}</navbar>
    <div class="card">
      <div class="name">
        <img src="@/assets/images/medicine_box.png" alt />
        <span>{{detailData.info ? detailData.info.realName:'--/--'}}</span>
      </div>
      <van-divider content-position="center">{{$t('detailList.details')}}</van-divider>
      <div class="mes">
        <div class="box">
          <p>
            <span>{{$t('detailList.gender')}}:</span>
            {{detailData.info ? detailData.info.gender == 1 ? '男':detailData.info.gender == 2 ? '女': '*':'--/--'}}
          </p>
          <p>
            <span>{{$t('detailList.medical_card_number')}}:</span>
            {{detailData.info ? detailData.info.medicalCardId:'--/--'}}
          </p>
          <p>
            <span>{{$t('detailList.department')}}:</span>
            {{detailData.info ? detailData.info.departmentName:'--/--'}}
          </p>
          <p>
            <span>{{$t('detailList.drug_allergy')}}:</span>
            {{detailData.info ? detailData.info.remark:'--/--'}}
          </p>
        </div>
        <div class="box">
          <p>
            <span>{{$t('detailList.age')}}:</span>
            {{detailData.info ? detailData.info.age:'--/--'}}
          </p>
          <p>
            <span>{{$t('detailList.hospital_name')}}:</span>
            {{detailData.info ? detailData.info.hospitalName:'--/--'}}
          </p>
          <p>
            <span>{{$t('detailList.doctors')}}:</span>
            {{detailData.info ? detailData.info.doctorName:'--/--'}}
          </p>
        </div>
      </div>
    </div>
    <van-divider>{{$t('detailList.ct_scan_list')}}</van-divider>
    <van-empty
      v-if="detailData.status == null"
      class="custom-image"
      image="https://img.yzcdn.cn/vant/custom-empty-image.png"
      :description="$t('detailList.scanerr_hint')"
    />
    <div class="list" v-else>
      <div class="child" v-for="(item,index) in detailData.dsResult" :key="index">
        <div class="left">
          <p class="num">{{index+1}}</p>
          <div class="date">
            <p>
              {{$t('detailList.ct_date')}}:
              <span>{{item.ctTime | time}}</span>
            </p>
            <p>
              {{$t('detailList.upload_time')}}:
              <span>{{item.ctTime}}</span>
            </p>
          </div>
        </div>
        <div>
          <van-button
            plain
            type="info"
            color="#4775d9"
            size="small"
            @click="toDetails(item)"
          >{{$t('detailList.see_details')}}</van-button>
          <van-button
            @click="toReport(item)"
            plain
            type="info"
            color="#4775d9"
            size="small"
          >{{$t('detailList.see_report')}}</van-button>
        </div>
      </div>
    </div>
    <van-empty
      v-if="detailData.dsResult && detailData.dsResult.length == 0 && detailData.status != null && detailData.status.status==2"
      :image="require('@/assets/images/nolung.png')"
      :description="$t('detailList.found')"
      class="custom-image"
    />
    <van-divider
      v-if="detailData.status != null&&  detailData.dsResult.length > 0"
    >{{$t('detailList.no_mores')}}</van-divider>
  </div>
</template>

<script>
import navbar from "@/components/navbar";
import { getPatient } from "@/api/noduleList.js";
import { Toast } from "vant";
export default {
  name: "lungList",
  components: { navbar },
  data() {
    return {
      detailData: []
    };
  },
  computed: {},
  watch: {},
  methods: {
    // 返回上一页
    goBack() {
      this.$router.back();
    },
    // 获取数据
    getData(id) {
      getPatient(id).then(res => {
        if (res.status.code == 200) {
          this.detailData = res.data;
          console.log(this.detailData);
        }
      });
    },
    // 跳转详情
    toDetails(item) {
      this.$router.replace({
        path: "/lungDetail",
        query: {
          dsId: item.dsId,
          patientId: item.patientId
        }
      });
    },
    // 报告
    toReport(item) {
      this.$router.replace({
        path: "/lungReport",
        query: {
          dsId: item.dsId,
          patientId: item.patientId
        }
      });
    }
  },
  async created() {
    let id = this.$route.query.id;
    await this.getData(id);
    let toast1 = Toast.loading({
      message: this.$t("detailList.loading"),
      forbidClick: true,
      overlay: true
    });
    Toast.setDefaultOptions({ duration: 500 });
  },
  mounted() {},
  destroyed() {},
  filters: {
    time(value) {
      let date = new Date(value.replace(/-/g, "/"));
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      if (month < 10) {
        month = "0" + month;
      }
      let day = date.getDate();
      if (day < 10) {
        day = "0" + day;
      }
      return year + "-" + month + "-" + day;
    }
  }
};
</script>
<style lang='scss' scoped>
.container {
  position: relative;
  height: 100vh;
  background: #f5f5f5;
  overflow-y: scroll;
  & .card {
    width: 94%;
    // height: 2rem;
    background: #ffffff;
    margin: 0 auto;
    margin-top: 10px;
    box-shadow: 0px 0px 10px #cccccc;
    & .van-divider {
      margin: 0;
      font-size: .14rem;
    }
    & .name {
      text-align: left;
      padding: .1rem .15rem;
      & img {
        width: .3rem;
        height: .3rem;
        vertical-align: middle;
      }
      & span {
        height: .22rem;
        vertical-align: middle;
        color: #4973d7;
        font-weight: 600;
        margin-left: .1rem;
        font-size: .2rem;
        display: inline-block;
        width: 2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
    & .mes {
      display: flex;
      justify-content: flex-start;
      padding-bottom: 15px;
      & .box {
        margin: 0 .3rem 0 .15rem;
        text-align: left;
        & p {
          & span {
            color: #8d898e;
            font-size: .14rem;
          }
          margin: 10px 0;
          font-size: .14rem;
        }
      }
    }
  }
  & .van-divider {
      font-size: .14rem;
    }
  & .list {
    width: 94%;
    margin: 0 auto;
    & .child {
      background: #ffffff;
      display: flex;
      height: 100px;
      justify-content: space-between;
      align-items: center;
      padding: 0 15px;
      border-radius: 10px;
      box-shadow: 4px 4px 10px #cccccc;
      margin-bottom: 15px;
      & .left {
        display: flex;
        align-items: center;
        & .num {
          font-size: 14px;
          color: #4973d7;
        }
        & .date {
          text-align: left;
          margin-left: .15rem;
          & p {
            font-size: .14rem;
            color: #999898;
            margin: 10px 0;
          }
          & span {
            font-size: .14rem;
            color: black;
          }
        }
      }
      & .van-button {
        display: block;
        margin-top: 5px;
      }
    }
  }
  .custom-image {
  & /deep/ .van-empty__image {
    width: .8rem;
    height: .8rem;
  }
  & /deep/ .van-empty__description {
    font-size: .14rem;
  }
}
}
</style>